
select * from ms_style_type where style_type = 'C-AS'
select * from ms_style_type where style_type = 'F-AS'

begin tran

declare @upd_id int
select @upd_id = convert(int, var_data) from igs_parm with(updlock) where var_name = 'gv_upd_id'

update ms_style_type set leaf_flag = 'N', upd_id = @upd_id where style_type = 'C-AS' 

update ms_style_type set type_tree = replace(type_tree, '.', '.C-AS.'), upd_id = @upd_id
where style_type in ('C-AC','C-BG','C-HT','C-SO','C-SS') and charindex('C-AS', type_tree) =0

update ms_style_type set leaf_flag = 'N', upd_id = @upd_id where style_type = 'C-EP' 

update ms_style_type set type_tree = replace(type_tree, '.', '.C-EP.'), upd_id = @upd_id
where style_type in ('C-CT','C-JK','C-LK','C-OP','C-SR','C-ST','C-SU','C-SW','C-TS','C-VE','C-WC') and 
		charindex('C-EP', type_tree) =0

update ms_style_type set leaf_flag = 'N', upd_id = @upd_id where style_type = 'C-PP' 

update ms_style_type set type_tree = replace(type_tree, '.', '.C-PP.'), upd_id = @upd_id
where style_type in ('C-DN','C-DNS','C-HD','C-LG','C-PT','C-PTS','C-SK') and 
		charindex('C-PP', type_tree) =0

update ms_style_type set leaf_flag = 'N', upd_id = @upd_id where style_type = 'F-AS' 

update ms_style_type set type_tree = replace(type_tree, '.', '.F-AS.'), upd_id = @upd_id
where style_type in ('F-AC','F-BG','F-ER','F-BT','F-HT','F-HW','F-SC','F-SO','F-SS') and 
		charindex('F-AS', type_tree) =0

update ms_style_type set leaf_flag = 'N', upd_id = @upd_id where style_type = 'F-EP' 

update ms_style_type set type_tree = replace(type_tree, '.', '.F-EP.'), upd_id = @upd_id
where style_type in ('F-CT','F-FR','F-HD','F-JK','F-LC','F-LK','F-OP','F-SR','F-ST','F-SU','F-SW','F-TS','F-VE','F-WC') and 
		charindex('F-EP', type_tree) =0

update ms_style_type set leaf_flag = 'N', upd_id = @upd_id where style_type = 'F-PP' 

update ms_style_type set type_tree = replace(type_tree, '.', '.F-PP.'), upd_id = @upd_id
where style_type in ('F-DN','F-DNS','F-LG','F-PT','F-PTS','F-SK','F-SP') and 
		charindex('F-PP', type_tree) =0

update ms_style_type set leaf_flag = 'N', upd_id = @upd_id where style_type = 'H-AS' 

update ms_style_type set type_tree = replace(type_tree, '.', '.H-AS.'), upd_id = @upd_id
where style_type in ('H-AC','H-BG','H-BT','H-ER','H-GF','H-GS','H-HT','H-SC','H-SO','H-SS' ) and 
		charindex('H-AS', type_tree) =0

update ms_style_type set leaf_flag = 'N', upd_id = @upd_id where style_type = 'H-EP' 

update ms_style_type set type_tree = replace(type_tree, '.', '.H-EP.'), upd_id = @upd_id
where style_type in ('H-CT','H-FR','H-HD','H-JK','H-LC','H-LK','H-SR','H-ST','H-SU','H-SW','H-TS','H-VE','H-WC') and 
		charindex('H-EP', type_tree) =0

update ms_style_type set leaf_flag = 'N', upd_id = @upd_id where style_type = 'H-PP' 

update ms_style_type set type_tree = replace(type_tree, '.', '.H-PP.'), upd_id = @upd_id
where style_type in ('H-DN','H-DNS','H-LG','H-PT','H-PTS','H-S') and 
		charindex('H-PP', type_tree) =0


select * from ms_style_type where style_type in ('C-AC','C-BG','C-HT','C-SO','C-SS') 
  
rollback tran
